package practice;

import java.util.*;

class CourseRecord {
    String courseName;
    int score;

    public CourseRecord(String courseName, int score) {
        this.courseName = courseName;
        this.score = score;
    }
}

class InteractionRecord {
    String interactionType;
    int score;

    public InteractionRecord(String interactionType, int score) {
        this.interactionType = interactionType;
        this.score = score;
    }
}
class Student {
    String studentId;
    String name;
    String className;
    String teacherName;
    List<CourseRecord> courseRecords;
    List<InteractionRecord> interactionRecords;
    List<Integer> assessmentScores;

    public Student(String studentId, String name, String className, String teacherName) {
        this.studentId = studentId;
        this.name = name;
        this.className = className;
        this.teacherName = teacherName;
        this.courseRecords = new ArrayList<>();
        this.interactionRecords = new ArrayList<>();
        this.assessmentScores = new ArrayList<>();
    }

    public void addCourseRecord(String courseName, int score) {
        courseRecords.add(new CourseRecord(courseName, score));
    }

    public void addInteractionRecord(String interactionType, int score) {
        interactionRecords.add(new InteractionRecord(interactionType, score));
    }

    public void addAssessmentScores(List<Integer> scores) {
        assessmentScores.addAll(scores);
    }

    public double getAverageCourseScore() {
        if (courseRecords.isEmpty()) {
            return 0;
        }
        int total = 0;
        for (CourseRecord record : courseRecords) {
            total += record.score;
        }
        return (double) total / courseRecords.size();
    }

    public int getMaxInteractionScore() {
        if (interactionRecords.isEmpty()) {
            return 0;
        }
        int max = Integer.MIN_VALUE;
        for (InteractionRecord record : interactionRecords) {
            if (record.score > max) {
                max = record.score;
            }
        }
        return max;
    }

    public int getMinAssessmentScore() {
        if (assessmentScores.isEmpty()) {
            return 0;
        }
        int min = Integer.MAX_VALUE;
        for (int score : assessmentScores) {
            if (score < min) {
                min = score;
            }
        }
        return min;
    }
}
public class HomeWork {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<String, Student> studentMap = new HashMap<>();
        while (true) {
            String line = scanner.nextLine();
            if ("exit1".equals(line)) {
                break;
            }
            String[] parts = line.split(",");
            String studentId = parts[0];
            String name = parts[1];
            String className = parts[2];
            String teacherName = parts[3];
            String courseName = parts[4];
            int score = Integer.parseInt(parts[5]);

            studentMap.computeIfAbsent(studentId, k -> new Student(studentId, name, className, teacherName))
                    .addCourseRecord(courseName, score);
        }
        while (true) {
            String line = scanner.nextLine();
            if ("exit2".equals(line)) {
                break;
            }
            String[] parts = line.split(",");
            String studentId = parts[0];
            String interactionType = parts[4];
            int score = Integer.parseInt(parts[5]);

            studentMap.computeIfAbsent(studentId, k -> new Student(studentId, "", "", ""))
                    .addInteractionRecord(interactionType, score);
        }
        while (true) {
            String line = scanner.nextLine();
            if ("exit3".equals(line)) {
                break;
            }
            String[] parts = line.split(",");
            String studentId = parts[0];
            List<Integer> scores = new ArrayList<>();
            for (int i = 4; i < parts.length; i++) {
                scores.add(Integer.parseInt(parts[i]));
            }

            studentMap.computeIfAbsent(studentId, k -> new Student(studentId, "", "", ""))
                    .addAssessmentScores(scores);
        }
        String queryId = scanner.nextLine();
        Student student = studentMap.get(queryId);
        if (student != null) {
            System.out.println(student.name);
            System.out.printf("作业平均分：%.1f\n", student.getAverageCourseScore());
            System.out.println("互动成绩最高分：" + student.getMaxInteractionScore());
            System.out.println("考核成绩最低分：" + student.getMinAssessmentScore());
        } else {
            System.out.println("未找到该学生信息");
        }
        scanner.close();
    }
}